package com.neuedu.cockpit.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.neuedu.cockpit.domain.HmFilePath;
import com.neuedu.cockpit.service.IHmFilePathService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neuedu.common.annotation.Log;
import com.neuedu.common.core.controller.BaseController;
import com.neuedu.common.core.domain.AjaxResult;
import com.neuedu.common.enums.BusinessType;
import com.neuedu.common.utils.poi.ExcelUtil;
import com.neuedu.common.core.page.TableDataInfo;

/**
 * 上次文件地址信息Controller
 * 
 * @author neuedu
 * @date 2024-04-26
 */
@RestController
@RequestMapping("/cockpit/path")
public class HmFilePathController extends BaseController
{
    @Autowired
    private IHmFilePathService hmFilePathService;

    /**
     * 查询上次文件地址信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HmFilePath hmFilePath)
    {
        startPage();
        List<HmFilePath> list = hmFilePathService.selectHmFilePathList(hmFilePath);
        return getDataTable(list);
    }

    /**
     * 新增上次文件地址信息
     */
    @Log(title = "上次文件地址信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmFilePath hmFilePath)
    {
        return toAjax(hmFilePathService.insertHmFilePath(hmFilePath));
    }

    /**
     * 修改上次文件地址信息
     */
    @Log(title = "上次文件地址信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmFilePath hmFilePath)
    {
        return toAjax(hmFilePathService.updateHmFilePath(hmFilePath));
    }

    /**
     * 删除上次文件地址信息
     */
    @Log(title = "上次文件地址信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {

        return toAjax(hmFilePathService.deleteHmFilePathByIds(ids));
    }

    /**
     * 通过文件名称，获取完整路径
     */
    @PostMapping("/picUrl")
    public AjaxResult getPicUrl(@RequestBody HmFilePath hmFilePath) {
        HmFilePath fp = hmFilePathService.selectHmFilePathByName(hmFilePath.getFileName());
        return AjaxResult.success(fp);
    }
}
